package com.haiya.state.threadstate;

public class RunningState extends ThreadState {
    public RunningState() {
        threadName = "运行状态";
        System.out.println("当前线程处于运行状态.~~~~~");
    }

    public void suspend(ThreadContext context) {
        System.out.print("调用suspend()方法-->");
        if (threadName.equals("运行状态")) {
            context.setState(new BlockedState());
        } else {
            System.out.println("当前线程不是新建状态，不能调用suspend方法.");
        }
    }

    public void stop(ThreadContext context) {
        System.out.print("调用stop()方法-->");
        if (threadName.equals("运行状态")) {
            context.setState(new DeadState());
        } else {
            System.out.println("当前线程不是新建状态，不能调用stop方法.");
        }
    }
}
